<?php
/*
* @Descripttion: 事件记录
* @Author: jiosen <4631458@qq.com>
* @Date: 2024-06-11 14:10:31
*/
namespace app\controller;

use app\BaseController;
use app\model\EventLog as ModelEventLog;

class EventLog extends BaseController
{
    public function index()
    {
        $page = $this->getPage();
        $where = [];

        $param = $this->request->param();

        $searchFields = ['post_type','message_type','sub_type','temp_source'];

        foreach($searchFields as $value)
        {
            if(isset($param[$value])){
                $where[] = [$value,'=',$param[$value]];
            }
        }

        $lists = ModelEventLog::where($where)->order('id desc')->limit($page['start'],$page['num'])->select();
        $count = ModelEventLog::where($where)->count();
        return $this->success('success',['lists'=>$lists,'total'=>$count]);
    }
}